Skip to content

Refactor/cpp client sdk#17801

Open
hongzhi-gao wants to merge 40 commits into
apache:masterfrom
hongzhi-gao:refactor/cpp-client-sdk
Open

Refactor/cpp client sdk#17801
hongzhi-gao wants to merge 40 commits into
apache:masterfrom
hongzhi-gao:refactor/cpp-client-sdk

Conversation

@hongzhi-gao
Copy link
Copy Markdown
Contributor

Summary

Refactor the C++ Session client packaging/build path to be release-friendly and integrator-friendly: single CMake entry, CI package matrix, flatter SDK zip layout, and checksum artifacts.


1. User-friendly release layout (flattened)

Release zip packages are intentionally minimal and now use a flat root layout:

  • include/ — public IoTDB Session API headers (e.g. Session.h, SessionBuilder.h, SessionC.h, Common.h, ...)
  • lib/ — one runtime library:
    • Linux: libiotdb_session.so
    • macOS: libiotdb_session.dylib
    • Windows: iotdb_session.dll + import iotdb_session.lib

Not shipped in the package (and not required by SDK consumers):

  • Apache Thrift headers/libs/generated artifacts
  • Boost headers/libs

Package artifact format:

  • client-cpp-<version>-<classifier>.zip
  • unzip result is directly include/ + lib/ at root (no extra nested directory layer)

Also added checksum generation:

  • client-cpp-<version>-<classifier>.zip.sha512

2. Ops-friendly CI: package matrix + validation

Release packaging workflow (client-cpp-package.yml)

The workflow builds and uploads one package per target/toolchain (triggered by manual dispatch, release:published, v* tags, and rc/** with C++ path changes):

Target Classifier Notes
Windows x64 + VS 2017 windows-x86_64-vs2017
Windows x64 + VS 2019 windows-x86_64-vs2019
Windows x64 + VS 2022 windows-x86_64-vs2022
Windows x64 + VS 2026 windows-x86_64-vs2026
Linux x86_64, glibc baseline 2.17 linux-x86_64-glibc217
Linux aarch64, glibc baseline 2.17 linux-aarch64-glibc217
Linux x86_64, glibc baseline 2.24 + CXX11 ABI linux-x86_64-glibc224
Linux aarch64, glibc baseline 2.24 + CXX11 ABI linux-aarch64-glibc224
macOS x86_64 mac-x86_64
macOS arm64 mac-aarch64

Workflow-level hardening:

  • uploads both .zip and .zip.sha512 artifacts together

3. Developer-friendly build model

C++ client is driven by a single entry point:

  • iotdb-client/client-cpp/CMakeLists.txt

CMake modules under cmake/ handle dependency/toolchain bootstrap and Thrift source generation. Build output is installed to target/install, then Maven wraps:

  • cmake configure/build/install
  • optional tests
  • assembly package
  • checksum generation

Standalone build remains supported:

cmake -S iotdb-client/client-cpp -B build && cmake --build build --target install

4. Additional cleanups included

  • merged C session examples into example/client-cpp-example
  • updated docs/examples to match new package layout and classifiers

…arty cache

Move C++ client dependency resolution and compilation into one top-level
CMakeLists with Fetch* modules, cache tarballs under third-party/<os>/ for
offline copy-the-repo workflows, and slim the Maven POM to a CMake wrapper.
Skip server CI when only client-cpp changes; gate multi-language-client jobs
by language via paths-filter.
Install Homebrew bison on macOS package/IT runners so Thrift 0.21.0 builds
(%code requires Bison 2.4+). Add client-cpp-source-build workflow that uses a
minimal toolchain and online CMake fetch to verify zero-to-build compilation.
Align Linux/macOS/Windows toolchain setup with client-cpp-package so
Spotless clang-format check during mvn package succeeds.
Source-build workflow focuses on minimal-toolchain CMake fetch; pass
-Dspotless.skip=true instead of installing clang-format on runners.
Reorganize sources into include/session/rpc with PIMPL so public headers no longer pull in Thrift or Boost. Embed Thrift in iotdb_session on all platforms; on Windows build a /MD shared library with import lib. Update examples, CI verification, and documentation for the slimmer SDK layout.
Fixes Linux CI build where convertToTimestamp/int32ToDate declarations require std::tm from <ctime> (C++11).
Pass CMAKE_POLICY_VERSION_MINIMUM=3.5 when configuring Thrift 0.21 on CMake 4.x (VS2026 CI). Include <cstring> in Session.cpp for memcpy/strlen/strstr on strict Linux builds.
Drop --whole-archive on Linux to avoid libgcc morestack duplicate symbols; build Thrift with -fno-split-stack. Bump default Boost to 1.84.0 for modern Clang on macOS CI.
Linux: keep --whole-archive for Thrift in libiotdb_session.so but add --allow-multiple-definition to avoid libgcc morestack duplicate symbols. macOS: default BOOST_VERSION to 1.84.0 for modern Clang enum checks (other platforms stay on 1.60.0).
Add per-classifier SDK packages (glibc 2.17 on CentOS 7, Windows VS2015-2026), workflow_dispatch variant filter, and documentation for choosing the right zip.
- paths-ignore C++ workflows/scripts on Java IT jobs; narrow C++ path filters (no root pom.xml)

- aarch64 package on Ubuntu 20.04 container (linux-aarch64-glibc231)

- CentOS7 script: vault repos, Adoptium API JDK, devtoolset deps

- VS2015/2017: pin boost-msvc-14.2/14.1 versions instead of missing boost-msvc-14.0
- glibc217/aarch64: checkout on host, build inside docker (fixes CentOS7 + Node 24)

- aarch64: install Kitware CMake 3.28 (ARCHIVE_EXTRACT needs 3.18+)

- Remove VS2015 package matrix and related docs
- Zip: client-cpp-<version>-<classifier>.zip (remove redundant -cpp- segment)

- Root folder client-cpp-<version>-<classifier>/ with include/ and lib/ inside

- Update examples (strip one dir on unpack), distribution assembly, CI artifact paths

- CentOS7 SCLo vault mirror fix; chown workspace after docker builds
centos-sclo-sclo baseurl with releasever=7 404s on vault; rewrite SCLo repo files and refresh yum cache before devtoolset-8 install.
Replace docker run on ubuntu-22.04 with job-level container quay.io/pypa/manylinux2014_x86_64 and checkout@v4, matching PyPA manylinux CI style.
Job container cannot run Node-based actions on glibc 2.17. Run checkout/cache on ubuntu-latest and build inside manylinux2014 via docker run; use preinstalled devtoolset-10 in the image.
Replace ldd | head -1 with sed -n 1p and find | head -1 with find -quit so glibc checks do not fail after a successful build.
VS2017 generator defaults to Win32; pass -DCMAKE_GENERATOR_PLATFORM=x64 on Windows via Maven profile. Add CI PE check that iotdb_session.dll is x64.
Use manylinux2014_aarch64 and the shared packaging script instead of Ubuntu 20.04 glibc231. Extend the script for aarch64 CMake/JDK arch and classifier auto-detection. Update docs and remove the obsolete ubuntu20-arm script.
Guard checkTemplateExists against a null dataset, document DataIterator lifetime, correct README Maven vs CMake option names, drop unused IotdbResolveTarball.cmake, and skip server CI when only multi-language-client workflow changes.
Rename the Linux packaging helper to a manylinux-specific script, drop unused CentOS7 fallback branches, and keep only build plus GLIBC<=2.17 verification steps. Also add concise C++ workflow comments and unify client-cpp CMake minimum version to 3.15.
Rename public Date type from IoTdbDate to IoTDBDate across headers, RPC/session code, and ITs. Move tests from src/test to a top-level test directory and update CMake, Maven, and README paths accordingly.
Move tree_example.c and table_example.c into client-cpp-example, build them from the shared CMake entry, and update EN/ZH docs. Remove the standalone client-c-example module and drop it from the with-cpp profile.
…linux_2_24

Add linux-*-glibc224 zips built on manylinux_2_24 with -D_GLIBCXX_USE_CXX11_ABI=1 wired through Session and Thrift. Document glibc224 as recommended over glibc217 for modern distros.
Drop client-cpp-source-build.yml; packaging is covered by client-cpp-package.yml.
Resolve sessionIT.cpp include conflict: keep Column.h (upstream column
tests) and Date.h (IoTDBDate), drop unused RpcCommon.h.
Fail manylinux package scripts when GLIBC symbols cannot be parsed, and remove stale client-cpp-source-build.yml path triggers left after that workflow was deleted.
Unpack directly to include/ and lib/ at zip root, generate .sha512 via checksum-maven-plugin, and upload checksums from the package workflow.
Maven wget in generate-test-resources; CMake file(DOWNLOAD) fallback; remove test/catch2/catch.hpp from source tree.
Run wget in generate-resources (not generate-test-resources, which runs after compile). CMake also downloads catch.hpp when the header is still missing.
Consolidate the current workspace changes across confignode, datanode, and client layers, including C++ session pooling and dataset handling updates, so the branch state is consistent and buildable for collaboration.
…urces

Place SessionPool.cpp under src/session to align with the existing source layout while keeping public headers in src/include.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the main difference between the two scripts?

Or, what made the compilation so different between 2.17 and 2.24? Is it possible to extract something in common?

├── include/
│ ├── Session.h
│ ├── Export.h
│ └── ... (17 public headers; no thrift/ or boost/)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to mention no thrift/ or boost/ any more.

New users should be free from the two words.

Comment on lines 60 to 69
std::string formatDatetime(const std::string& format, const std::string& precision,
int64_t timestamp, const std::string& zoneId) {
// Simplified implementation - in real code you'd use proper timezone handling
(void)precision;
(void)zoneId;
std::time_t time = static_cast<std::time_t>(timestamp);
std::tm* tm = std::localtime(&time);
char buffer[80];
strftime(buffer, sizeof(buffer), format.c_str(), tm);
return std::string(buffer);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just remove the unused parameters?

Comment on lines +28 to +35
std::string IoTDBDate::toIsoExtendedString() const {
if (!valid_) {
return "";
}
char buf[16];
std::snprintf(buf, sizeof(buf), "%04d-%02d-%02d", year_, month_, day_);
return std::string(buf);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the valid_ from? Is it thread local?

Comment on lines +43 to +51
if (year < 1000 || year > 9999) {
throw DateTimeParseException("Year must be between 1000 and 9999.", date.toIsoExtendedString(),
0);
}

const int64_t result = static_cast<int64_t>(year) * 10000 + date.month() * 100 + date.day();
if (result > INT32_MAX || result < INT32_MIN) {
throw DateTimeParseException("Date value overflow. ", date.toIsoExtendedString(), 0);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Necessary to check month and day?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants